package com.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by 41579 on 2016/8/24.
 */
public class Test {
    public static void main(String[] args) {
//        new ReekCustomer().goTaiwan();
//        System.out.println("==========================");
//        new TaobaoProxy(new RichCustomer()).goTaiwan();
        InvocationHandler handler = new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("办理台湾通行证");
                System.out.println("办理台湾出入证");
                System.out.println("买去机票");
                method.invoke(RichCustomer.class.newInstance(),args);
                System.out.println("买回来的机票");
                return null;
            }
        };
        ITravel obj =(ITravel)Proxy.newProxyInstance(ITravel.class.getClassLoader(), ITravel.class.getInterfaces(), handler);
        obj.goTaiwan();
        //       ProxyUtils.generateClassFile(RichCustomer.class,"testProxy");
    }
}
